<?php
namespace Api\Controller;
use Think\Controller;
class GameController extends Controller {

    /*俱乐部列表  开发人：周弈男*/
    public function allgame(){
       $game=M('game');
       $game=$game->select();
       if($game==null){
          $this->ajaxReturn($game);
       }else{
          $this->ajaxReturn($game);
       }
    }

    public function follow(){
      $follow=M('follow');
      $gameid=$_GET['gameid'];
      $uid=$_GET['uid'];
      $type=$_GET['type'];

      $data['userid']=trim($uid);
      $data['type']=trim($type);
      $data['id']=trim($gameid);
      $exist=$follow->where($data)->find();
      if($exist!==null){
        $re['success']='0';
        $follow=$follow->where($data)->delete();
        $this->ajaxReturn($re);
      }else{
        $re['success']='1';
        $follow=$follow->add($data);
        $this->ajaxReturn($re);
      }
    }

    public function isCollected(){
      $follow=M('follow');
      $gameid=$_GET['gameid'];
      $uid=$_GET['uid'];
      $type=$_GET['type'];

      $data['userid']=trim($uid);
      $data['type']=trim($type);
      $data['id']=trim($gameid);
      $exist=$follow->where($data)->find();
      if($exist!==null){
        $re['collected']='1';
        $this->ajaxReturn($re);
      }else{
        $re['collected']='0';
        $this->ajaxReturn($re);
      }
    }
}
